package logic

import (
	"context"
	"store-kit/models/mysql"

	"store-kit/storerpc/internal/svc"
	"store-kit/storerpc/storerpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type ListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListLogic {
	return &ListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *ListLogic) List(in *storerpc.ListRequest) (*storerpc.ListResponse, error) {
	// todo: add your logic here and delete this line
	store := mysql.Store{
		Name: in.Name,
		Num:  int(in.Num),
	}
	mysql.DB.Debug().Find(&store)

	return &storerpc.ListResponse{
		StoreId: int64(store.ID),
	}, nil
}
